import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        System.out.println("输入字符串:");
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int flag = 0;
        char[] line1 = line.toCharArray();
        if(line1[0]!=' '){
            flag++;
        }
        for (int i = 1; i <line.length() ; i++) {
            if(line1[i-1]==' '&&line1[i]!=' '){
                flag++;
            }
        }
        System.out.println("有"+flag+"个单词");
    }
}
